package com.haojin.exer1;

public class Account {

	private int id;//账户
	private double balance;//余额
	private double annuallnterestRate;//年利率
	private double overdraft;//可透支额
	
	
	//空参构造器
	public Account(){
		
	}
	//构造器
	public Account(int id, double balance, double annuallnterestRate) {
		super();
		this.id = id;
		this.balance = balance;
		this.annuallnterestRate = annuallnterestRate;
	}
	
	public Account(int id, double balance, double annuallnterestRate, double overdraft) {
		super();
		this.id = id;
		this.balance = balance;
		this.annuallnterestRate = annuallnterestRate;
		this.overdraft = overdraft;
	}
	public double getOverdraft() {
		return overdraft;
	}
	public void setOverdraft(double overdraft) {
		this.overdraft = overdraft;
	}
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(double balance) {
		this.balance = balance;
	}

	public double getAnnuallnterestRate() {
		return annuallnterestRate;
	}

	public void setAnnuallnterestRate(double annuallnterestRate) {
		this.annuallnterestRate = annuallnterestRate;
	}
	
	public double getMonthlylnterest(){//返回月利率的方法
		return annuallnterestRate/12;
	}
	
	public void withdraw(double amount){//取款方法
		if(amount > balance){
			System.out.println("余额不足，取款失败。");
			System.out.println("您的账户余额为："+balance);
		}else{
				balance -= amount;
		System.out.println("取款成功，余额为："+balance);
		}
	
	}
	
	public void deposit(double amount) {// 存款方法
		if (amount > 0) {
			balance += amount;
			System.out.println("存款成功，余额为：" + balance);
			System.out.println("储蓄的月利率为：" + getMonthlylnterest() + "%");
		}

	}

}

